﻿package {

	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import flash.media.Video;
	import flash.net.NetStream;
	import com.media.controllers.FLVController;
	import com.media.displays.FLVDisplay;
	import com.events.MediaEvent;
	
	public class MediaPlayer extends Sprite {

		private var _flvController:FLVController;
		private var _flvDisplay:FLVDisplay;
		
		public function MediaPlayer() {
			trace("MediaPlayer");
			init();
		}
		
		private function init():void {
			_flvController = new FLVController();
			_flvController.addEventListener(Event.INIT,mediaInit, false, 0, true);
			_flvController.addEventListener(MediaEvent.COMPLETE,mediaComplete, false, 0, true);
			_flvDisplay = new FLVDisplay();
			addChild(_flvDisplay);
			_flvDisplay.x = 0;//115;
			_flvDisplay.y = 0;//80;
			_flvDisplay.displayWidth = 320;
			_flvDisplay.displayHeight = 240;
			_flvDisplay.setController(_flvController);
			_flvController.loadMedia("video/afraid.flv");
			stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDown, false, 0, true);
		}
		
		private function mediaInit(pEvent:Event):void {
			trace("FLV init");
		}
		private function mediaComplete(pEvent:MediaEvent):void {
			trace("FLV complete");
		}
		private function mouseDown(pEvent:MouseEvent):void {
			_flvController.pauseMedia(!_flvController.paused);
		}
	}


}